<?php
/**
 * Created by PhpStorm.
 * User: chniccs
 * Date: 2019-12-17
 * Time: 16:42
 */

namespace app\admin\controller;


use app\model\AppUserBill;
use app\util\ReturnCode;
use think\exception\DbException;

class Bill extends Base
{

    public function getBill()
    {
        $limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT'));
        $start = $this->request->get('page', 1);
        $type = $this->request->get('type', null, 'intval');
        $where = $this->addTid([]);
        $obj = new AppUserBill();
        if (isset($type))
            $where['type'] = $type;
        try {
            $listObj = $obj->where($where)->order('create_time')->paginate($limit, false, ['page' => $start])->toArray();
            return $this->buildSuccess([
                'list' => $listObj['data'],
                'count' => $listObj['total']
            ]);
        } catch (DbException $e) {
        }
        return $this->buildFailed(ReturnCode::FAILED, '获取失败');
    }
}